<?php
include_once 'module/conn.php';
include_once 'common/tools.php';

$matchId = $_GET["matchId"];
$matchCategory = $_GET["matchCategory"];

$config = require 'conf/config.ini.php';      //加载公用config.ini.php
$conn = mysql_connect($config["DB_HOST"], $config["DB_USER"], $config["DB_PWD"]);
mysql_select_db($config["DB_NAME"], $conn);
mysql_query("SET NAMES utf8");

$sql = NULL;
if ($matchCategory == "1") {
	$sql = "select 	ms.id,ifnull(m.memberNo,ms.id) no,ms.name,ms.first,ms.team " .
			"from 	live_member_stats_b ms left join live_member_b m on ms.id = m.memberId " .
			"where  ms.matchId = '" . $matchId . "'";
} else
	if ($matchCategory == "2" || $matchCategory == "3") {
		$sql = "select id,id no,name,first,team from live_member_stats_f where matchId = '" . $matchId . "'";
	}
$statsList = mysql_query($sql, $conn);
if (mysql_num_rows($statsList) > 0) {
	while ($stats = mysql_fetch_object($statsList)) {
		$statsArray[] = $stats;
	}

	//启用一个带有ob_gzip压缩机的工作台
	ob_start('ob_gzip');

	echo '{"result":"Y","results":' . json_encode($statsArray) . '}';
} else {
	echo '{"sql":"' . $sql . '","result":"N"}';
}

//输出压缩成果
ob_end_flush();
?>